package com.example.test.dialogfactory;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import androidx.appcompat.app.AppCompatActivity;
import easier.log.logger.Logger;

public class MainActivity79 extends AppCompatActivity {

    private Button mCallFinish;
    private Button mSetOk;
    private Button mSetResult100;

    public static void startActivityForResult( Activity context, int request ) {

        Intent starter = new Intent( context, MainActivity79.class );
        context.startActivityForResult( starter, request );
    }

    @Override
    protected void onCreate( Bundle savedInstanceState ) {

        super.onCreate( savedInstanceState );
        setContentView( R.layout.activity_main79 );
        initView();
    }

    @Override
    public void onBackPressed() {

        super.onBackPressed();
        Logger.i( "onBackPressed" );
    }

    @Override
    public void finish() {

        super.finish();
        Logger.i( "finish" );
    }

    private void initView() {

        mCallFinish = (Button) findViewById( R.id.callFinish );
        mSetOk = (Button) findViewById( R.id.setOk );

        mCallFinish.setOnClickListener( new OnClickListener() {
            @Override
            public void onClick( View v ) {

                finish();
            }
        } );

        mSetOk.setOnClickListener( new OnClickListener() {
            @Override
            public void onClick( View v ) {

                setResult( RESULT_OK );
                finish();
            }
        } );

        mSetResult100 = (Button) findViewById( R.id.setResult100 );
        mSetResult100.setOnClickListener( new OnClickListener() {
            @Override
            public void onClick( View v ) {

                setResult( 100 );
                finish();
            }
        } );
    }
}